package com.best.oasis.settlement.util
{
	
	public class NumberUtils
	{
		import mx.collections.ArrayCollection;
        import flash.utils.describeType;
        import mx.utils.ObjectUtil;
        import flash.utils.getDefinitionByName;
        
		public function NumberUtils()
		{
		}
       
		/**
		 * 判断一个字符串是否是数字
		 * 
		 */
		public static function isNumber(str:String):Boolean{
			if(str==null || str.length==0){
				return false;
			}
			
			var hasNonDigitalCharactor:Boolean = false;
			var dotNumber:int = 0;
			for(var i:int=0; i< str.length; i++){
				var c:String = str.charAt(i);
				if( ! ( (c >='0' && c<='9') || c=='.' ) ){
					hasNonDigitalCharactor = true;
					break;
				}
				if(c=='.'){
					dotNumber++;
				}
			}
				
			if(hasNonDigitalCharactor==true){
				// 有非数字和“.”的字符
				return false;
			}
			
			if(dotNumber>1){
				// 小数点大于1个
				return false;
			}
			
			return true;
		}
		
		/**
		 * is Not a Number?
		 * 
		 */
		public static function isNaN(str:String):Boolean{
			return (isNumber(str)==false);
		}
		
		/**
		 * 为了不显示NaN
		 * 
		 */
		public static function toString(num:Number):String{
			return NumberUtilsHelper.toString(num);
		}
		
		/**
		 * 将字符串解析为Number
		 * 
		 */
		public static function parseNumber(str:String):Number{
			if ( isNaN( str )  ){
				return Number.NaN;	
			}else{
				return new Number( str );
			}
		}
		
	} 
	
}